﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

using SCS.Web.UI.WebControls;

public partial class SelectionSample : System.Web.UI.Page 
{
    public void Toolbar1_ButtonClicked(object sender, ButtonEventArgs e)
    {
        string msg = "";

        if (Toolbar1.SelectionMode != SelectionModeType.Off)
        {
            if (Toolbar1.SelectionMode == SelectionModeType.Single)
            {
                msg = "Item Selected: "
                    + ((e.SourceButton.Text != "") ? e.SourceButton.Text : e.SourceButton.Index.ToString());
            }
            else
            {
                msg = "Items Selected: ";

                foreach (ToolbarButton button in Toolbar1.Items)
                    if (button.Selected)
                        msg += button.Index.ToString() + " ";
            }
        }

        ButtonClickedText.Text = msg; 
    }

    protected override void OnLoad(EventArgs e)
    {
        base.OnLoad(e);
    
        Toolbar1.SelectionMode = (SelectionModeType)Enum.Parse(typeof(SelectionModeType), SelectionTypeSelect.SelectedItem.Value);
    }
}
